<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>后台管理</title>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> 
<link href="<%=path %>/static/miniui/themes/default/demo.css" rel="stylesheet"
	type="text/css" />
<style type="text/css">
body {
	margin: 0;
	padding: 0;
	border: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}
</style>

<script src="<%=path %>/static/miniui/boot.js"
	type="text/javascript"></script>

<!--引入皮肤样式-->
<link href="<%=path %>/static/miniui/themes/blue/skin.css"
	rel="stylesheet" type="text/css" />

</head>
<body> 
 <div style="width:800px;">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" iconCls="icon-add" onclick="add()" plain="true" tooltip="增加...">增加</a>
                           <a class="mini-button" iconCls="icon-remove" onclick="remove()" plain="true">删除</a>
                      <!--   <span class="separator"></span> -->
                          <a class="mini-button" iconCls="icon-add" onclick="edit()" plain="true">编辑</a>     
                    </td>
                    <td style="white-space:nowrap;">
                   
                       <input id="key" class="mini-textbox" emptyText="发帖人" style="width:150px;" onenter="onKeyEnter"/>   
                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>   
  
<div id="datagrid1" class="mini-datagrid" style="width:800px;height:280px;" 
    url="replyList"  idField="userid" allowResize="true"  dataField="list"
    sizeList="[5,20,50,100]" pageSize="20" totalField="totalField" allowCellEdit="true" allowCellSelect="true" multiSelect="true" 
        editNextOnEnterKey="true"  editNextRowCell="true"
>
    <div property="columns" id="form1"> 
            <div type="indexcolumn"> 编号</div>   
            <div type="checkcolumn"></div>
        <div  field="replyid" width="100" headerAlign="center" allowSort="true">回帖编号
         <!--  <input  id="postid" class="mini-spinner" style="width:100%;" minWidth="200" readonly="readonly"/> --></div>   
      
                              
        <div  field="replyUsername" width="100" renderer="onGenderRenderer" align="center" headerAlign="center">回帖人  </div>
         <div  field="replyContent" width="100" renderer="onGenderRenderer" align="center" headerAlign="center">回帖内容 </div>                    
         <div id="postCreatetime" name="replyCreatetime" field="replyCreatetime" width="100" allowSort="true" dateFormat="yyyy-MM-dd" >回帖时间
               
            </div>  
  
    </div>
</div>   
   
    <script type="text/javascript">
    mini.parse();
  
   
    var grid = mini.get("datagrid1");

   // grid.load(); 
    grid.sortBy("replyid", "asc");
    var db = new mini.DataBinding();
    
    db.bindForm("form1", grid);
   
    function remove() {
        
        var rows = grid.getSelecteds();  
        if (rows.length > 0) {
            if (confirm("确定删除选中记录？")) {
                var ids = [];
                for (var i = 0, l = rows.length; i < l; i++) {
                    var r = rows[i];
                    ids.push(r.replyid);
                }
                var id = ids.join(',');         
                grid.loading("操作中，请稍后......");
                $.ajax({
                    url: "delete?id=" +id,
                    success: function (text) {
                        grid.reload();
                    },
                    error: function () {
                    }
                });
            }
        } else {
            alert("请选中一条记录");
        }
    }
   
     function edit() {
         
         var row = grid.getSelected();  
       
         if (row) {
             mini.open({
                 url: "<%=path%>/back/postInformation",
                 title: "编辑", width: 600, height: 360,
                 onload: function () {
                     var iframe = this.getIFrameEl();
                     var data = { action: "edit", id: row.replyid };
           
                     iframe.contentWindow.SetData(data);
                     
                 },
                 ondestroy: function (action) {
                     grid.reload();
                     
                 }
             });
             
         } else {
             alert("请选中一条记录");
         }
         
     }
   /*  function saveData() {
    	  var rows = grid.getSelecteds();
          if (rows.length > 0) {
          	
       
        var data = grid.getChanges();
        var json = mini.encode(data);
     
        grid.loading("保存中，请稍后......");
        $.ajax({
            url: "save",
            data: { data: json },
            type: "post",
            success: function (text) {
                grid.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                alert(jqXHR.responseText);
            }
        });
          }else{
       
        	 alert("请选中一条记录");
          }
    } */
     function add() {
            
            mini.open({
            	 url: "<%=path%>/back/postInformation",
                title: "新增发帖信息", width: 600, height: 360,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new"};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {

                    grid.reload();
                }
            });
        }
       function search() {
            var key = mini.get("key").getValue();
        	grid.load({ key: key });
        }
        function onKeyEnter(e) {
            search();
        } 
       
      
    </script>
</body>
</html>